B_1=importdata('reportB_1.txt');
B_2=importdata('reportB_2.txt');
B_3=importdata('reportB_3.txt');
B_4=importdata('reportB_4.txt');
x=linspace(-5,5,10000);
for i=1:10000
   y(i)=1/(1+x(i)*x(i)); 
end

n=2;
b_1=ones(n+1,10000);
for i=2:n+1
    for j=1:10000
        b_1(i,j)=b_1(i-1,j)*(x(j)+5-10*(i-2)/n);
    end
end
y_1=B_1'*b_1;


n=4;
b_2=ones(n+1,10000);
for i=2:n+1
    for j=1:10000
        b_2(i,j)=b_2(i-1,j)*(x(j)+5-10*(i-2)/n);
    end
end
y_2=B_2'*b_2;


n=6;
b_3=ones(n+1,10000);
for i=2:n+1
    for j=1:10000
        b_3(i,j)=b_3(i-1,j)*(x(j)+5-10*(i-2)/n);
    end
end
y_3=B_3'*b_3;


n=8;
b_4=ones(n+1,10000);
for i=2:n+1
    for j=1:10000
        b_4(i,j)=b_4(i-1,j)*(x(j)+5-10*(i-2)/n);
    end
end
y_4=B_4'*b_4;

fig=figure(1);hold on;
plot(x,y);plot(x,y_1);plot(x,y_2);plot(x,y_3);plot(x,y_4);
hold off;
frame=getframe(fig);
img=frame2im(frame);
imwrite(img,'B.png');
